<!DOCTYPE html>
<html>
<head><meta name="generator" content="Hexo 3.8.0">
  <meta charset="utf-8">
  
  <title>橙子Android技术研究室</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta property="og:type" content="website">
<meta property="og:title" content="橙子Android技术研究室">
<meta property="og:url" content="http://yoursite.com/index.html">
<meta property="og:site_name" content="橙子Android技术研究室">
<meta property="og:locale" content="default">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="橙子Android技术研究室">
  
    <link rel="alternate" href="/atom.xml" title="橙子Android技术研究室" type="application/atom+xml">
  
  
    <link rel="icon" href="/favicon.png">
  
  
    <link href="//fonts.googleapis.com/css?family=Source+Code+Pro" rel="stylesheet" type="text/css">
  
  <link rel="stylesheet" href="/css/style.css">
  

</head>
</html>
<body>
  <div id="container">
    <div id="wrap">
      <header id="header">
  <div id="banner"></div>
  <div id="header-outer" class="outer">
    <div id="header-title" class="inner">
      <h1 id="logo-wrap">
        <a href="/" id="logo">橙子Android技术研究室</a>
      </h1>
      
        <h2 id="subtitle-wrap">
          <a href="/" id="subtitle">小时候的味道</a>
        </h2>
      
    </div>
    <div id="header-inner" class="inner">
      <nav id="main-nav">
        <a id="main-nav-toggle" class="nav-icon"></a>
        
          <a class="main-nav-link" href="/">Home</a>
        
          <a class="main-nav-link" href="/archives">Archives</a>
        
      </nav>
      <nav id="sub-nav">
        
          <a id="nav-rss-link" class="nav-icon" href="/atom.xml" title="RSS Feed"></a>
        
        <a id="nav-search-btn" class="nav-icon" title="Search"></a>
      </nav>
      <div id="search-form-wrap">
        <form action="//google.com/search" method="get" accept-charset="UTF-8" class="search-form"><input type="search" name="q" class="search-form-input" placeholder="Search"><button type="submit" class="search-form-submit">&#xF002;</button><input type="hidden" name="sitesearch" value="http://yoursite.com"></form>
      </div>
    </div>
  </div>
</header>
      <div class="outer">
        <section id="main">
  
    <article id="post-自定义View-点击可旋转的饼状图" class="article article-type-post" itemscope="" itemprop="blogPost">
  <div class="article-meta">
    <a href="/2018/11/04/自定义View-点击可旋转的饼状图/" class="article-date">
  <time datetime="2018-11-04T13:55:55.000Z" itemprop="datePublished">2018-11-04</time>
</a>
    
  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2018/11/04/自定义View-点击可旋转的饼状图/">自定义View 点击可旋转的饼状图</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <p>最近看到有人讨论这个需求的实现，原文地址（<a href="https://www.jianshu.com/p/18b0676904b0）。" target="_blank" rel="noopener">https://www.jianshu.com/p/18b0676904b0）。</a></p>
<p>我觉得作者的思路还是挺清晰的，但是实现还是有点问题，并且个人觉得效率不高。</p>
<p>个人的改进意见是通过path去实现，在调用setDatas（）方法时即可将所有饼块的path路径计算出来。整体实现思路有如下几个优点：</p>
<ol>
<li>所有色块在设置数据时就已经计算完成，无需在onDraw（）方法绘制时再计算。</li>
<li>动画效果可以直接通过画布的旋转实现。</li>
<li>选中项的效果可以直接通过在旋转的基础上增加平移即可，不会产生角度问题。</li>
</ol>
<p>代码后续实现上传</p>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://yoursite.com/2018/11/04/自定义View-点击可旋转的饼状图/" data-id="cjo2zeq6500000dickzsl8xmm" class="article-share-link">Share</a>
      
      
    </footer>
  </div>
  
</article>


  

</section>
        
          <aside id="sidebar">
  
    

  
    

  
    
  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Archives</h3>
    <div class="widget">
      <ul class="archive-list"><li class="archive-list-item"><a class="archive-list-link" href="/archives/2018/11/">November 2018</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Recent Posts</h3>
    <div class="widget">
      <ul>
        
          <li>
            <a href="/2018/11/04/自定义View-点击可旋转的饼状图/">自定义View 点击可旋转的饼状图</a>
          </li>
        
      </ul>
    </div>
  </div>

  
</aside>
        
      </div>
      <footer id="footer">
  
  <div class="outer">
    <div id="footer-info" class="inner">
      &copy; 2018 citsin<br>
      Powered by <a href="http://hexo.io/" target="_blank">Hexo</a>
    </div>
  </div>
</footer>
    </div>
    <nav id="mobile-nav">
  
    <a href="/" class="mobile-nav-link">Home</a>
  
    <a href="/archives" class="mobile-nav-link">Archives</a>
  
</nav>
    

<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>


  <link rel="stylesheet" href="/fancybox/jquery.fancybox.css">
  <script src="/fancybox/jquery.fancybox.pack.js"></script>


<script src="/js/script.js"></script>

  </div>
</body>
</html>